package com.lagou.springbootjpathymeleaf.example.web;

import com.lagou.springbootjpathymeleaf.example.model.Article;
import com.lagou.springbootjpathymeleaf.example.service.BlogSystemService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
public class BlogSystemController {

    @Resource
    BlogSystemService blogSystemService;


    @RequestMapping("/list")
    public String findAllBlogs(ModelMap modelMap, @RequestParam(value="page",required = false,defaultValue = "0") Integer page, @RequestParam(value="size",required = false,defaultValue = "1") Integer size  ){
        Page<Article> datas = blogSystemService.find(page, size);
        modelMap.addAttribute("datas", datas);
        return "index";
    }

}
